package com.tledu.equipment.controller;

import com.tledu.common.annotation.Log;
import com.tledu.common.core.controller.BaseController;
import com.tledu.common.core.domain.AjaxResult;
import com.tledu.common.core.page.TableDataInfo;
import com.tledu.common.enums.BusinessType;
import com.tledu.common.utils.poi.ExcelUtil;
import com.tledu.equipment.domain.EquipmentLog;
import com.tledu.equipment.service.IEquipmentLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 操作日志Controller
 * 
 * @author ruoyi
 * @date 2024-08-29
 */
@RestController
@RequestMapping("/equipment/equipmentlog")
public class EquipmentLogController extends BaseController
{
    @Autowired
    private IEquipmentLogService equipmentLogService;

    /**
     * 查询操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('equipment:equipmentlog:list')")
    @GetMapping("/list")
    public TableDataInfo list(EquipmentLog equipmentLog)
    {
        startPage();
        List<EquipmentLog> list = equipmentLogService.selectEquipmentLogList(equipmentLog);
        return getDataTable(list);
    }

    /**
     * 导出操作日志列表
     */
    @PreAuthorize("@ss.hasPermi('equipment:equipmentlog:export')")
    @Log(title = "操作日志", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EquipmentLog equipmentLog)
    {
        List<EquipmentLog> list = equipmentLogService.selectEquipmentLogList(equipmentLog);
        ExcelUtil<EquipmentLog> util = new ExcelUtil<EquipmentLog>(EquipmentLog.class);
        util.exportExcel(response, list, "操作日志数据");
    }

    /**
     * 获取操作日志详细信息
     */
    @PreAuthorize("@ss.hasPermi('equipment:equipmentlog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(equipmentLogService.selectEquipmentLogById(id));
    }

    /**
     * 新增操作日志
     */
    @PreAuthorize("@ss.hasPermi('equipment:equipmentlog:add')")
    @Log(title = "操作日志", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EquipmentLog equipmentLog)
    {
        return toAjax(equipmentLogService.insertEquipmentLog(equipmentLog));
    }

    /**
     * 修改操作日志
     */
    @PreAuthorize("@ss.hasPermi('equipment:equipmentlog:edit')")
    @Log(title = "操作日志", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EquipmentLog equipmentLog)
    {
        return toAjax(equipmentLogService.updateEquipmentLog(equipmentLog));
    }

    /**
     * 删除操作日志
     */
    @PreAuthorize("@ss.hasPermi('equipment:equipmentlog:remove')")
    @Log(title = "操作日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(equipmentLogService.deleteEquipmentLogByIds(ids));
    }

    /**
     * 逻辑删除操作日志
     */
    @PreAuthorize("@ss.hasPermi('equipment:equipmentlog:remove')")
    @Log(title = "操作日志", businessType = BusinessType.DELETE)
    @PutMapping("/{ids}")
    public AjaxResult logicRemove(@PathVariable Long[] ids)
    {
        return toAjax(equipmentLogService.LogicDeleteEquipmentLogByIds(ids));
    }


}
